<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>在vue中同时使用过渡和动画</title>
    <link rel="stylesheet" href="./css/animate.css">
    <script src="./js/vue.js"></script>
    <style>
    /* 使用过度效果 */
    .fade-enter{
        opacity: 0;
    }
    .fade-enter-active{
        transition: opacity 3s;
    }
    .fade-leave-to{
        opacity: 0;
    }
    .fade-leave-active{
        transition: opacity 3s;
    }
    </style>
</head>
<body>
    <div id="root">
            <!--
                1.设置appear  appear-active-class设置页面初次打开时的动画
                2.animated的动画时长为1s, 过渡时长为3s, 
                在transition标签里设置type="transition"则以transition的时间为准
                3.或者时长自定义：在transition标签设置:duration='10000'，动画时长即为10s,
                enter和leave时间可以分开设置:duration='{enter: 5000, leave: 10000}'
            -->
        <transition  
            name="fade" 
            :duration="1000" 
            appear 
            enter-active-class="animated shake fade-enter-active" leave-active-class="animated shake fade-leave-active"
            appear-active-class="animated swing"
        >
            <div v-if="show">hello vue!</div>
        </transition>
        <button @click="handleBtnClick">切换</button>
    </div>
    <script>
        var vm = new Vue({
            el: "#root",
            data: {
                show: true
            },
            methods: {
                handleBtnClick: function(){
                    this.show = !this.show;
                }
            }
        });
    </script>
</body>
</html>